package com.simple.controller.operator;

import com.simple.entity.operator.Operator;
import com.simple.service.operator.OperatorService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping(value = "/simple")
@CrossOrigin(allowCredentials = "true")
public class OperatorController {

    @Autowired
    private OperatorService operatorService;

    @GetMapping("/addOperator")
    public void addOperator(Operator operator){
        operatorService.addOperator(operator);
    }

    @GetMapping("/deleteOperator")
    public void deleteOperator(int operatorId){
        operatorService.deleteOperator(operatorId);
    }

    @GetMapping("/updateOperator")
    public void updateOperator(Operator operator){
        operatorService.updateOperator(operator);
    }

    @GetMapping("/findOperatorById")
    public Operator findOperatorById(@Param("operatorId") int operatorId){
        return operatorService.findOperatorById(operatorId);
    }

    @GetMapping("/findAllOperators")
    public List<Operator> findAllOperators(){
        return operatorService.findAllOperators();
    }
}
